﻿using AntMovement.Comm;
using AntMovement.Core;
using AntMovement.Core.Entity;
using AntMovement.Core.Enum;
using AntMovement.Core.IParameter;
using AntMovement.Core.LabelService;
using AntMovement.Core.Model;
using AntMovement.Core.Model.Interaction;
using AntMovement.Parameter.Model;
using AntMovernent.SolidTechESerialCard.Domain;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AntMovement.Parameter
{
    public class TemporaryParameter : AntMovement.Core.Mvvm.ViewModelBase, ITemporaryParameter
    {
        private bool _runLabelService;
        /// <summary>
        /// 启动标签服务器
        /// </summary>
        public bool RunLabelService
        {
            get { return _runLabelService; }
            set { SetProperty(ref _runLabelService, value); }
        }

        /// <summary>
        /// 软件状态  false 停止  true 运行
        /// </summary>
        private bool _StatusSoftware;

        public bool Status_Software
        {
            get { return _StatusSoftware; }
            set { SetProperty(ref _StatusSoftware, value); }
        }

        /// <summary>
        /// 设备状态
        /// </summary>
        private StatusDeviceType _StatusDevice = StatusDeviceType.板卡未连接;
        /// <summary>
        /// 1 手动 2 自动运行 3 报警
        /// </summary>
        public StatusDeviceType Status_Device
        {
            get { return _StatusDevice; }
            set { SetProperty(ref _StatusDevice, value); }
        }
        public AntMovement.Core.Model.SystemStatusModel SystemStatus { get; set; }

        #region 全局变量
        public bool NG满料 { get; set; }
        public bool OK满料 { get; set; }

        #region FPC摆盘机
        public StationStatusModel Status_Z轴 { get; set; }
        public StationStatusModel Status_料盘固定 { get; set; }
        public StationStatusModel Status_模组运动 { get; set; }
        #endregion

        #region 结果信号
        public bool OK { get; set; }
        public bool NG { get; set; }
        #endregion
        #region 定点移动
        public bool FixedPointMove { get; set; }
        public string FixedPointName { get; set; }

        public double FixedPointDistance { get; set; }
        #endregion
        /// <summary>
        /// 一键回原
        /// </summary>
        public bool OneKeyHome { get; set; }

        private bool _HomeComplete;
        /// <summary>
        /// 回原完成
        /// </summary>
        public bool HomeComplete
        {
            get { return _HomeComplete; }
            set { SetProperty(ref _HomeComplete, value); }
        }
        #region 轴
        #region 独立回原
        public bool AxisHome { get; set; }
        public string AxisNameHome { get; set; }
        #endregion
        #region 轴Jog

        public bool JogUp { get; set; }
        public bool JogDown { get; set; }
        #endregion
        #region 点位运动
        public bool JogMove { get; set; }
        public string JogName { get; set; }
        #endregion
        #region 轴使能
        public string ServoName { get; set; }
        public bool ServoEnable { get; set; }
        #endregion
        #endregion
        public int MaterielCount { get; set; }
        /// <summary>
        /// 标定
        /// </summary>
        public bool Calibration { get; set; }
        /// <summary>
        /// 标定号
        /// </summary>
        public int CalibrationIndex { get; set; }
        /// <summary>
        /// 纠偏
        /// </summary>
        public bool Orientation { get; set; }
        /// <summary>
        /// 定位结果
        /// </summary>
        public int RrsultOrientation { get; set; }
        public List<BackOrientationModel> BackOrientation { get; set; }
        #endregion
        #region 交互变量
        private ITagManager _tagManager;
        public VisualInteractionDataModel VisualInteraction { get; set; }
        #endregion

        #region 往返运动参数
        public string NamePointRound { get; set; }
        public bool RunPointRound { get; set; }
        public ObservableCollection<PointRoundTripModel> PointRoundTrips { get; set; }
        #endregion
        #region 单周
        public bool Monocycle { get; set; }
        #endregion
        #region 屏蔽
        public bool ShieldYAxisVariableSpeed { get; set; }
        #endregion
        public TemporaryParameter()
        {
            PointRoundTrips = new ObservableCollection<PointRoundTripModel>();
            SystemStatus = new Core.Model.SystemStatusModel();
            VisualInteraction = new VisualInteractionDataModel();
            BackOrientation = new List<BackOrientationModel>();
            try
            {
                //_tagManager = new TagManager();
                //_tagManager.Parsing.AddTag("VI", VisualInteraction);
                //AntService uDPService = new AntService(_tagManager);
                //RunLabelService = uDPService.Open();
            }
            catch (Exception)
            {
            }
        }

        public StatusDeviceType GetStatus() => Status_Device;
        public bool GetConnect() => Status_Software;
    }
}
